package com.witframework.core.structure;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;

import org.apache.log4j.Logger;
import org.javalid.annotations.core.JvGroup;
import org.javalid.annotations.validation.LovConstraint;

import com.witframework.core.annotations.Wit;


/**
 * Base business object, the root of the inheritance tree for all business objects.
 * The class model here combines an inheritance structure with interface definitions. 
 * @author wuxinyang
 * Jun 5, 2009 9:55:34 AM
 * 
 */
@MappedSuperclass 
public class BaseWitObject extends com.witframework.core.BaseEntity 
	implements ActiveEnabled{
	
	private static final Logger log = Logger.getLogger(BaseWitObject.class);
	
	private static final long serialVersionUID = 1L;		
	
	@Wit(cnname="激活?",description="是否激活状态，1：是，其他：否")	
	@Column(length = 1,columnDefinition="varchar(1) default 'Y'")  
	@LovConstraint (values={"Y","N"},type="java.lang.String")
	@JvGroup (groups={"inheritance"},exposeInSubClass=true)
	private String isactive="Y";
	
	@Wit(cnname="创建时间",description="创建时间")
	@Column
	private Date created;
	
	@Wit(cnname="创建者",description="创建者")
	@Column(length = 32,columnDefinition="varchar(32) default 'SYSTEM'")
	private String createdby;
	
	@Wit(cnname="更新时间",description="更新时间")
	@Column
	private Date updated=new java.util.Date();
	
	@Wit(cnname="更新者",description="更新者")	
	@Column(length = 32)
	@JvGroup (groups={"inheritance"},exposeInSubClass=true)
	private String updatedby;
	
	@Column(length=32)
	private String adOrgId;
	
	public String getIsactive() {
		return isactive;
	}

	public void setIsactive(String isactive) {
		this.isactive = isactive;
	}

	
	public Date getCreated() {
		return created;
	}
	public void setCreated(Date created) {
		this.created = created;
	}
	
	public String getCreatedby() {		
		return createdby;
	}

	public void setCreatedby(String createdby) {
		this.createdby = createdby;
	}
	
	public Date getUpdated() {
		if(updated==null)
			return new java.util.Date();
		return updated;
	}
	public void setUpdated(Date updated) {
		this.updated = updated;
	}

	
	public String getUpdatedby() {
		return updatedby;
	}
	public void setUpdatedby(String updatedby) {
		this.updatedby = updatedby;
	}
	
	
	
	
	public boolean isActive() {		
		return getIsactive()!=null&&getIsactive().equals("1")?true:false;
	}
	public void setActive(boolean active) {
		if(active)
			setIsactive("Y");
		else
			setIsactive("N");
	}
	public String getAdOrgId() {
		return adOrgId;
	}
	public void setAdOrgId(String adOrgId) {
		this.adOrgId = adOrgId;
	}
	

	
}
